<template>
  <div>
    <div class="header" id="header">
      <router-link to="/percen">
        <div class="header_back">
          <div class="header_back_r">《</div>
        </div>
      </router-link>
      <div id="head-title">我的资产</div>
      <router-link to="/" class="gb-head-rightwrap" data-ajax="false">
        <div class="header_right">
          <p class="capital-detailed" href="/user/assets/detailed">资金明细</p>
        </div>
      </router-link>
    </div>
    <div class="capital-header">
      <div class="capital-Available">
        可用余额<br />
        <span>{{ name.money }}</span>
      </div>
      <van-cell class="capital-waiting" @click="showPopup">充值</van-cell>
      <van-popup v-model="show">
        <img src="../assets/img/1.jpg" alt="" style="width: 200px" />
        <van-form @submit="onSubmit">
          <van-field
            v-model="money"
            name="money"
            label="充值"
            placeholder="请充值"
            :rules="[{ required: true, message: '请充值' }]"
          />
          <div style="margin: 16px">
            <van-button round block type="info" native-type="submit"
              >充值</van-button
            >
          </div>
        </van-form></van-popup
      >
      <van-cell class="capital-waiting" @click="showPopup">提现</van-cell>
      <van-popup v-model="show">
        <img src="../assets/img/1.jpg" alt="" style="width: 200px" />
        <van-form @submit="onSubmit">
          <van-field
            v-model="money"
            name="money"
            label="充值"
            placeholder="请充值"
            :rules="[{ required: true, message: '请充值' }]"
          />
          <div style="margin: 16px">
            <van-button round block type="info" native-type="submit"
              >提交</van-button
            >
          </div>
        </van-form></van-popup
      >
    </div>

    <div class="capital-box">
      <ul>
        <a href="/user/coupon/index">
          <li class="capital-coupon">
            <img
              src="https://m.taoshouyou.com/img/percenter/youhui.png"
            />优惠券
          </li>
        </a>
        <a href="/user/bank/index">
          <li class="capital-bank">
            <img
              src="https://m.taoshouyou.com/img/percenter/zhanghu.png"
            />收款账户管理
          </li>
        </a>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      show: false,
      money: "",
    };
  },

  methods: {
    showPopup() {
      this.show = true;
    },
    onSubmit(values) {
      this.$store.commit("percen/addmoney", values);
      this.show=false
    },
  },
  computed: {
    i() {
      return this.$store.state.percen.i;
    },
    name() {
      return this.$store.state.percen.user;
    },
  },
};
</script>
<style src="../assets/css/site.css" scoped></style>
<style lang="less" scoped>
.van-overlay {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
}
.van-cell__value--alone {
  color: #fff;
  text-align: center;
}
.capital-box ul {
  padding: 0;
  margin: 0;
}

.capital-box ul a li {
  border-bottom: 1px solid #f7f7f7;
  padding: 0.1rem 3% 0.1rem;
  background: url(https://m.taoshouyou.com/img/percenter/youj-icon.png)
    no-repeat;
  background-position: right;
  background-origin: content-box;
}

.capital-coupon,
.capital-bank {
  border-top: 10px solid #f7f7f7;
}

.capital-box ul a li img {
  height: 0.3rem;
  position: relative;
  top: 0.1rem;
  padding-right: 0.4rem;
}

.capital-detailed {
  font-size: 13px;
  color: #fff !important;
  float: right;
  position: fixed;
  right: 12px;
}

.capital-header {
  width: 100%;
  height: 1.5rem;
  background: url(https://m.taoshouyou.com/img/percenter/user-bg1.jpg) no-repeat;
  background-size: 100% 100%;
}

.capital-Available {
  text-align: center;
  color: #fff;
  height: 1.5rem;
  line-height: 0.5rem;
  padding: 0.5rem 0 0.5rem 0;
}

.capital-Available span {
  font-size: 18px;
}

.capital-frozen,
.capital-waiting {
  width: 50%;
  float: left;
  text-align: center;
  color: #fff;
  background: #f60045;
  padding: 0.5rem 0;
  font-size: 12px;
}

.capital-frozen span,
.capital-waiting span {
  font-size: 15px;
}

.capital-alert-bg {
  background: rgba(0, 0, 0, 0.3);
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  z-index: 99;
  display: none;
}

.capital-alert-bg .capital-alert-box {
  position: absolute;
  top: 39%;
  left: 50%;
  transform: translate(-50%);
  background: #fff;
  padding: 9px 14px;
  border-radius: 4px;
  width: 68%;
}

.capital-alert-box .capital-aler-text {
  color: red;
  font-weight: bold;
  font-size: 16px;
  text-align: center;
  line-height: 31px;
}

.capital-alert-box .capital-aler-title {
  text-align: left;
  font-weight: bold;
  font-size: 14px;
}

.capital-alert-box .capital-aler-right {
  text-align: right;
  font-size: 12px;
}
</style>